<?php
//新闻添加
if(!empty($_POST)){

	//加载初始化文件
    include_once('init.php');

    //获取$_POST数据
    $title = $_POST['title'];

    $type = $_POST['type'];

    $content = $_POST['content'];

    $author = $_POST['author'];

    $send_user = $_SESSION['admin']['username'];

    //编写插入的sql语句
    $sql = "insert into `news` (`title`,`type`,`content`,`author`,`send_user`)values('$title','$type','$content','$author','$send_user')";

    //执行语句
    mysqli_query($link,$sql);

    //获取刚刚执行的添加语句受影响的行数(就是你插入的数据的记录总数)
    $_rows = mysqli_affected_rows($link);

    if($_rows>0){
       echo '<script>alert("数据添加成功");location.href="news_list.php";</script>';die;
    }else{
    	echo '<script>alert("数据添加失败");history.go(-1);</script>';die;
    }

}


include('news_add.html');